package com.feng.designpattern.Singleton;

// Since this isn't inherited from a Cloneable
// base class and cloneability isn't added,
// making it final prevents cloneability from
// being added in any derived classes:
public class SingletonPattern {
	public static void main(String[] args) {
		Singleton s = Singleton.getHandle();
		System.out.println(s.getValue());
		Singleton s2 = Singleton.getHandle();
		s2.setValue(9);
		System.out.println(s.getValue());
		try {
			// Can't do this: compile-time error.
			// Singleton s3 = (Singleton)s2.clone();
		} catch (Exception e) {
		}
	}
}